C++ Windows Programming by 2016
Author:2016
Language: eng
Format: epub, mobi
Publisher: Packt Publishing
The parser – Generating the syntax tree
The user inputs a formula beginning with an equal sign (=). The parser's task is to translate the scanner's token list into a syntax tree. The syntax of a valid formula can be defined by a grammar. Let's start with a grammar that handles expressions that make use of the arithmetic operators:
A grammar is a set of rules. In the preceding grammar, there are eight rules. Formula and Expression are called non-terminals; EndOfLine, Value, and the characters +, -, *, /, (, and ) are called terminals. Terminals and non-terminals are called symbols. One of the rules is the grammar's start rule, in our case the first rule. The symbol to the left of the start rules is called the grammar's start symbol, in our case Formula.
The arrow can be read as "is", and the preceding grammar can be read as:
A formula is an expression followed by end-of-line. An expression is the sum of two expressions, the difference of two expressions, the product of two expressions, the quotient of two expressions, an expression enclosed by parentheses, a reference, or a numerical value.
This is a good start, but there are a few problems. Let's test if the string 1 + 2 * 3 is accepted by the grammar. We can test that by doing a derivation, where we start with the start symbol Formula and apply the rules until there are only terminals. The digits in the following derivation refer to the grammar rules:
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Deep Learning with Python by François Chollet(12570)
Hello! Python by Anthony Briggs(9915)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9796)
The Mikado Method by Ola Ellnestam Daniel Brolund(9778)
Dependency Injection in .NET by Mark Seemann(9337)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8296)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7763)
Grails in Action by Glen Smith Peter Ledbrook(7696)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7557)
Becoming a Dynamics 365 Finance and Supply Chain Solution Architect by Brent Dawson(7072)
Microservices with Go by Alexander Shuiskov(6834)
Practical Design Patterns for Java Developers by Miroslav Wengner(6755)
Test Automation Engineering Handbook by Manikandan Sambamurthy(6697)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6413)
Angular Projects - Third Edition by Aristeidis Bampakos(6099)
The Art of Crafting User Stories by The Art of Crafting User Stories(5628)
NetSuite for Consultants - Second Edition by Peter Ries(5562)
Demystifying Cryptography with OpenSSL 3.0 by Alexei Khlebnikov(5369)
Kotlin in Action by Dmitry Jemerov(5062)
